﻿namespace Digitalmes.Application.Sys.Dicts.Queries;

/// <summary>
/// 字典数据项分页查询命令。
/// </summary>
/// <param name="DictId"></param>
public record GetDictDataWithPagedQuery(long DictId) : PagedQuery, IRequest<IResult<PagedList<SysDictDataDto>>>;

internal sealed class GetDictDataWithPagedQueryHandler(IRepository<SysDictData> repo) : IRequestHandler<GetDictDataWithPagedQuery, IResult<PagedList<SysDictDataDto>>>
{
    public async Task<IResult<PagedList<SysDictDataDto>>> Handle(GetDictDataWithPagedQuery request, CancellationToken cancellationToken)
    {
        var ret = await repo.GetPagedListAsync(m => m.DictId == request.DictId, request.PageNumber, request.PageSize, cancellationToken);
        return Result.From(ret.Adapt<PagedList<SysDictDataDto>>());
    }
}
